package com.networkmanagerj.SwingView;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import com.networkmanagerj.message.response.ArpTableElement;

public class ArpTableModel extends AbstractTableModel {

	private List<ArpTableElement> listaArp;
	private String[] titulos ;
	public static Integer COLUNA_IP = 0;
	public static Integer COLUNA_NOME = 1;
	public static Integer COLUNA_DESCRICAO = 2;
	public static Integer COLUNA_MARCA = 3;
	public static Integer COLUNA_ATIVO = 4;
	public static Integer COLUNA_ULT_MSG = 5;
	public ArpTableModel(List<ArpTableElement> lista) {
		listaArp = lista;
		titulos = new String[2];
		titulos[0] = "Mac";
		titulos[1] = "Ip";
	}

	@Override
	public int getColumnCount() {
		return titulos.length;
	}

	@Override
	public int getRowCount() {
		return listaArp.size();
	}

	@Override
	public Object getValueAt(int linha, int coluna) {
		switch (coluna) {
		case 0:
			return listaArp.get(linha).getMac();
		case 1:
			return listaArp.get(linha).getIp();
		default:
			break;
		}
		return "";
	}

	public List<ArpTableElement> getListaAps() {
		return listaArp;
	}
 
	public ArpTableElement getAp(int linha){
		return listaArp.get(linha);
	}
	
	public void setListaArp(List<ArpTableElement> listaAps) {
		this.listaArp = listaAps;
		fireTableDataChanged();
	}
	
	@Override
	public String getColumnName(int column) {
		return titulos[column];
	}
}
